package com.yl.auth.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yl.auth.entity.LoginBean;
import com.yl.auth.service.LoginService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 王帅洋
 * @datetime 2023/6/30 20:29
 * @description 类对象
 */
@RestController
@RequestMapping("/yl/login")
@Api(tags = "管理员登入接口")


public class LoginController {
    @Resource
    private LoginService loginService;

    @ApiOperation(value = "登入接口")
    @PostMapping("/getLogin")
    public Result getLogin(@RequestBody LoginBean loginBean){
        QueryWrapper<LoginBean> queryWrapper = new QueryWrapper<LoginBean>();
        if(loginBean.getUsername()!=null&&loginBean.getPassword()!=null){
            queryWrapper.eq("username",loginBean.getUsername());
            queryWrapper.eq("password",loginBean.getPassword());
        }
        LoginBean one = loginService.getOne(queryWrapper);
        Map<String, Object> map = new HashMap<>();
        map.put("token",one);
        return Result.ok(map);
    }
}
